;1.用ADC0809实现数据采集，结果用8255C口
;送LED显示，LED全亮到全灭
;2.将转化结果送到2位数码管显示3.0
CODE SEGMENT
    ASSUME CS:CODE
    AAA8255 EQU 8000H
    BBB8255 EQU 8002H
    CCC8255 = 8004H
    CON8255 = 8006H
    ADC0809 = 0E002H;/Y6 1 1 1 0 IN1 2   IN6 C
    START:
    ;8255初始化
    MOV DX,CON8255
    MOV AL,80H
    OUT DX,AL
    ;adv0809启动转换
ABC:    MOV DX,ADC0809
    MOV AL,0
    OUT DX,AL
    ;调用延时子程序大约100微秒
    MOV CX,0FFH
    LOOP $
    ;读取转换结果数据从ADC0809到CPU内部AL寄存器
    MOV DX,ADC0809 
    IN AL,DX 
    ;将AL寄存器数据送到8255C口
    MOV DX, CCC8255
    OUT DX, AL     
    JMP ABC
    CODE ENDS     

END START


;用adc0809实现数据采集(0-5v)结果用8255C口
;送LED显示，LED从全亮到全
;2将转换结果送2位数码管显示  
CODE SEGMENT
      ASSUME CS:CODE  
      AAA8255 EQU  8000H
      BBB8255 EQU  8002H
      CCC8255 EQU     8004H
      CON8255 EQU     8006H
      ADC0809 EQU    0E00CH;/Y6        a3 a2 a1 0
     START:                          ;0110
                   
                   
     ; 8255初始化 
     
     MOV DX,CON8255
     MOV AL,80H
     OUT DX,AL
     ;调用adc0809  启动转换   
ABC: MOV DX,ADC0809
     MOV AL,0
     OUT DX,AL
     
     
     ;  延长子程序  大概100us
     MOV CX,00FFH
     LOOP $
     ;读取转换结果    
     MOV DX,ADC0809
     IN AL,DX
     
     MOV DX,CCC8255
     OUT DX,AL
     JMP ABC
     ;
    CODE ENDS 
END START




CODE SEGMENT
      ASSUME CS:CODE  
      AAA8255 EQU  8000H
      BBB8255 EQU  8002H
      CCC8255 EQU  8004H
      CON8255 EQU  8006H
      ADC0809 EQU  0E00CH ; ADC0809地址

START:                          ; 程序入口
     ; 8255初始化 
     MOV DX, CON8255
     MOV AL, 80H            ; 设置8255为模式 0
     OUT DX, AL

ABC: 
     ; 调用ADC0809启动转换   
     MOV DX, ADC0809
     MOV AL, 0              ; 启动转换
     OUT DX, AL
     
     ; 延时子程序，大约100us
     MOV CX, 00FFH  
     LOOP $


     ; 读取转换结果    
     MOV DX, ADC0809
     IN AL, DX              ; 从ADC读取结果
     
     ; 将结果送到8255
     MOV DX, CCC8255
     OUT DX, AL             ; 发送结果到8255

     ; 结果显示到数码管
     MOV DX, AAA8255
     OUT DX, AL            

     JMP ABC               

CODE ENDS 
END START




CODE SEGMENT
      ASSUME CS:CODE  
      AAA8255 EQU  8000H
      BBB8255 EQU  8002H
      CCC8255 EQU  8004H
      CON8255 EQU  8006H
      ADC0809 EQU  0E00CH 

START:                   
     MOV DX, CON8255
     MOV AL, 80H            
     OUT DX, AL

ABC: 
     MOV DX, ADC0809
     MOV AL, 0           
     OUT DX, AL
     MOV CX, 00FFH  
     LOOP $
     MOV DX, ADC0809
     IN AL, DX            
     MOV DX, CCC8255
     OUT DX, AL            
     MOV DX, AAA8255
     OUT DX, AL          
     JMP ABC               

CODE ENDS 
END START